package com.tsintergy.tmosguide.casemng.serviceimpl.facade.impl;

import com.tsieframework.core.base.service.BaseFacadeServiceImpl;
import com.tsintergy.tmosguide.casemng.serviceapi.facade.api.CaseDataFacadeService;
import com.tsintergy.tmosguide.casemng.serviceapi.facade.api.dto.CaseClrUnitPowerDTO;
import com.tsintergy.tmosguide.casemng.serviceapi.facade.api.dto.CaseUnitPowerFcDTO;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author longyz
 */
@Service("casemngFacadeService")
public class CaseDataFacadeServiceImpl extends BaseFacadeServiceImpl implements CaseDataFacadeService {

    @Override
    public List<CaseClrUnitPowerDTO> queryClrUnitPowerList(String caseId, List<String> unitIdList) {
        List<CaseClrUnitPowerDTO> caseClrUnitPowerDTOList = new ArrayList<>();
        for (String unitId : unitIdList) {
            CaseClrUnitPowerDTO dto = new CaseClrUnitPowerDTO();
            caseClrUnitPowerDTOList.add(dto);
            dto.setUnitId(unitId);
            dto.setUnitName("##" + unitId + "机组");
            List<BigDecimal> tvPower = new ArrayList<>();
            for (int i = 0; i < 96; i++) {
                //BigDecimal使用String为参数的构造函数，否则精度丢失
                tvPower.add(new BigDecimal("" + i + ".1"));
            }
            List<BigDecimal> tvPrice = new ArrayList<>();
            for (int i = 0; i < 96; i++) {
                //BigDecimal使用String为参数的构造函数，否则精度丢失
                tvPrice.add(new BigDecimal("100"));
            }
            dto.setTvPower(tvPower);
            dto.setTvPrice(tvPrice);
        }

        return caseClrUnitPowerDTOList;
    }
    
    @Override
    public List<CaseUnitPowerFcDTO> queryUnitPowerFcList(String caseId, List<String> unitIdList) {
        List<CaseUnitPowerFcDTO> resultList = new ArrayList<>();
        for (String unitId : unitIdList) {
            CaseUnitPowerFcDTO dto = new CaseUnitPowerFcDTO();
            resultList.add(dto);
            dto.setUnitId(unitId);
            dto.setUnitName("##" + unitId + "机组");
            List<BigDecimal> tvPower = new ArrayList<>();
            for (int i = 0; i < 96; i++) {
                //BigDecimal使用String为参数的构造函数，否则精度丢失
                tvPower.add(new BigDecimal("" + i));
            }
            dto.setTvPower(tvPower);
        }
        return resultList;
    }
}
